package com.jumper.study.admin.dto.excel;

import java.util.stream.Stream;

public enum GenderEnum {
    UNKNOWN(0, "未知"),
    MALE(1, "男"),
    FEMALE(2, "女");

    private final Integer value;

    private final String description;

    private GenderEnum(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public Integer getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public static GenderEnum convert(Integer value) {
        return Stream.of(values())
                    .filter(bean -> bean.value.equals(value))
                    .findAny()
                    .orElse(UNKNOWN);
    }

    public static GenderEnum convert(String desc) {
        return Stream.of(values())
                    .filter(bean -> bean.description.equals(desc))
                    .findAny()
                    .orElse(UNKNOWN);
    }
}
